package edu.chl.dat255.bluebanana.presentation.impl;

import edu.chl.dat255.bluebanana.R;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

public class ProfileSettings extends ListActivity {
	private long profileId;;
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		profileId = getIntent().getLongExtra("Profile", -1);

		String[] mainSettings = getResources().getStringArray(R.array.mainSettings);

		setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, mainSettings));

		ListView lv = getListView();
		lv.setTextFilterEnabled(true);

		lv.setOnItemClickListener(new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
				Intent intent = null;

				if (((TextView) view).getText().equals("Basic")) {
					intent = new Intent(ProfileSettings.this, BasicProfileSettings.class);
				} else if (((TextView) view).getText().equals("Sound")) {
					intent = new Intent(ProfileSettings.this, SoundProfileSettings.class);
				} else if (((TextView) view).getText().equals("Screen")) {
					intent = new Intent(ProfileSettings.this, ScreenProfileSettings.class);
				} else if (((TextView) view).getText().equals("Calls and messages")) {
					intent = new Intent(ProfileSettings.this, CommunicationProfileSettings.class);
				}
				if(intent != null) {
					intent.putExtra("Profile", profileId);
					startActivity(intent);
				}
			}
		});
	}
}
